var partitionLabels = function(S) {
    var letterlist = new Array(26), result = [], start = 0, end = 0;
    var first_a = 'a'.codePointAt(0);
    // 遍历字符串 找到每个字符最后一个字符的索引
    for(let i=0,j=0;i<S.length;i++){
        letterlist[S[i].codePointAt(0)-first_a] = i; // 每个字符从左到右依次记录
    }
    for(let i=0;i<S.length;i++){
        end = Math.max(end, letterlist[S[i].codePointAt(0)-first_a]); 
        // 肯定会有个字符包裹住前面所有的字符
        if(i === end){ // 达到最大截取长度
            result.push(end-start+1); 
            start = end+1;
        }
    }
    console.log(result);
    // letterlist = letterlist.filter(value => value !== undefined);
    // console.log(letterlist);
};

console.log(('a').codePointAt(0))
partitionLabels('ababcbacadefegdehijhklij');